<template>
	<view>
		<input type="text" v-model="echo" placeholder="echo信息" />
		<button type="primary" @click="sendEcho">发送echo</button>
	</view>
	<view class="">
		{{result}}
	</view>

	<view class="">
		<input type="text" v-model="user.username" placeholder="登录名" />
		<input type="password" v-model="user.password" placeholder="密码" />
		<button type="warn" @click="login">登录</button>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		api
	} from '../../script/api.js'

	const echo = ref('')
	const result = ref({})

	const sendEcho = () => {
		api.get('/test/echo', {
			echo: echo.value
		}, (data) => {
			result.value = data
		})
	}
	// 用户登录
	const user = ref({
		"username": "",
		"password": "",
	})

	const login = () => {
		api.post('/auth', user.value, (data) => {
			result.value = data
		})
	}
</script>

<style lang="scss">

</style>